﻿@using TaskoMask.BuildingBlocks.Contracts.Dtos.Comments
@using TaskoMask.Clients.UserPanel.Pages.Comments.Components

<div class="list-group task-list-group mb-3">
    <div class="list-group-item task-list-group-header">
        <strong>
            <i class="bi bi-list-task"></i>
            Comments
        </strong>
    </div>
    @foreach (var item in Model)
    {
        <a @onclick="@(()=>ShowUpdateCommentModal(item.Id))">
            <div class="list-group-item task-list-group-item">
                <small>
                    @item.Content
                   <span class="text-muted badge bg-light-gray"> @item.CreationTime.CreateDateTimeString</span>
                </small>
            </div>
        </a>
    }

    <div class="list-group-item task-list-group-item">
        <AddComment TaskId=@TaskId></AddComment>
    </div>
</div>



@code {
    [Parameter]
    public IEnumerable<GetCommentDto> Model { get; set; }

    [Parameter]
    public string TaskId { get; set; }





    /// <summary>
    ///
    /// </summary>
    private void ShowUpdateCommentModal(string id)
    {
        var parameters = new ModalParameters();
        parameters.Add(nameof(Pages.Comments.Components.UpdateComment.Id), id);
        ModalService.Show<Pages.Comments.Components.UpdateComment>("Update Comment", parameters, new ModalOptions { Class="blazored-modal w-75 w-md-50 bg-light-gray"});
    }

}
